Skip to content

fix(tools): inspect latest non-transient content in LoadArtifactsTool - #8441

Open
Echolonius wants to merge 1 commit into
google:mainfrom
Echolonius:fix/load-artifacts-with-preload-memory
Open

Echolonius wants to merge 1 commit into
google:mainfrom
Echolonius:fix/load-artifacts-with-preload-memory

Conversation

@Echolonius

Copy link
Copy Markdown

Link to Issue or Description of Change

Problem:
When PreloadMemoryTool runs before LoadArtifactsTool in Agent.tools, PreloadMemoryTool calls LlmRequest._insert_transient_user_content(), which appends a transient user Content after the function_response turn in llm_request.contents. Because LoadArtifactsTool._append_artifacts_to_llm_request() only inspected llm_request.contents[-1], it missed the load_artifacts function_response and omitted the requested artifact contents from the next model request.

Solution:
In LoadArtifactsTool._append_artifacts_to_llm_request(), walk reversed(llm_request.contents) skipping entries tracked in llm_request._transient_user_contents so the latest non-transient content is inspected regardless of tool ordering, while still avoiding re-loading artifacts from earlier turns when a new user message follows.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Ran:

  • uv run pytest tests/unittests/tools/test_load_artifacts_tool.py tests/unittests/tools/test_preload_memory_tool.py -q (79 passed)
  • uv run pytest tests/unittests/models/test_llm_request.py -q (40 passed)

@google-cla

google-cla Bot commented Nov 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Preloading memory makes load_artifacts omit an existing file and use the old meeting schedule

1 participant